<!DOCTYPE html >
<html lang="zh-CN">

    <head>
        <meta charset="utf-8">
        <meta http-equiv="pragma" content="no-cache">
        <meta http-equiv="cache-control" content="no-cache">
        <meta http-equiv="expires" content="0">
        <meta name="viewport" content="width=device-width, initial-scale=1,maximum-scale=1,user-scalable=no">
        <title>device</title>
        <link rel="stylesheet" href="../common/mui/mui.css" />
        <link rel="stylesheet" href="../common/common.css" />
    </head>

    <body>

        <div class="mui-content pt0">
            <ul class="mui-table-view ">
                <li class="mui-table-view-cell">
                    <a class="mui-navigate-right api-class" id="setOrientation">setOrientation(设置横屏)</a>
                </li>
                <li class="mui-table-view-cell">
                    <a class="mui-navigate-right api-class" id="setOrientation2">setOrientation(设置竖屏)</a>
                </li>
                <li class="mui-table-view-cell">
                    <a class="mui-navigate-right api-class" id="setOrientation3">setOrientation(设置跟随系统)</a>
                </li>
                <li class="mui-table-view-cell">
                    <a class="mui-navigate-right api-class" id="getDeviceId">getDeviceId(获取设备唯一ID)</a>
                </li>
                <li class="mui-table-view-cell">
                    <a class="mui-navigate-right api-class" id="getVendorInfo">getVendorInfo(获取代理商信息)</a>
                </li>
                <li class="mui-table-view-cell">
                    <a class="mui-navigate-right api-class" id="getNetWorkInfo">getNetWorkInfo(获取网络状态信息)</a>
                </li>
                <li class="mui-table-view-cell">
                    <a class="mui-navigate-right api-class" id="callPhone">callPhone(拨打电话)</a>
                </li>
                <li class="mui-table-view-cell">
                    <a class="mui-navigate-right api-class" id="sendMsg">sendMsg(发送短信)</a>
                </li>
                <li class="mui-table-view-cell">
                    <a class="mui-navigate-right api-class" id="closeInputKeyboard">closeInputKeyboard(关闭软键盘)</a>
                </li>
                <li class="mui-table-view-cell">
                    <a class="mui-navigate-right api-class" id="vibrate">vibrate(震动)</a>
                </li>
            </ul>
        </div>
        <script type="text/javascript" src="../common/mui/mui.js"></script>
        <script type="text/javascript" src="../../dist/quick.js"></script>
        <script type="text/javascript" src="../../dist/quick.native.js"></script>
        <script type="text/javascript" src="../../dist/quick.h5.js"></script>
        <script type="text/javascript" src="../common/common.js"></script>
        <script>
            quick.error(function(message) {
                alert('错误:' + JSON.stringify(message));
            });
            quick.config();
            quick.ready(function() {
                showTips('注册成功');
            });
            window.runApi = function(id) {
                console.log('执行API:' + id);

                switch (id) {
                    case 'setOrientation':
                        quick.device.setOrientation({
                            // 1表示竖屏，0表示横屏，其他表示跟随系统
                            orientation: 0,
                            success: function(result) {
                                showTips(JSON.stringify(result));
                            },
                            error: function(error) {
                                showTips('失败:' + JSON.stringify(error));
                            }
                        });
                        break;
                    case 'setOrientation2':
                        quick.device.setOrientation({
                            // 1表示竖屏，0表示横屏，其他表示跟随系统
                            orientation: 1,
                            success: function(result) {
                                showTips(JSON.stringify(result));
                            },
                            error: function(error) {
                                showTips('失败:' + JSON.stringify(error));
                            }
                        });
                        break;
                    case 'setOrientation3':
                        quick.device.setOrientation({
                            // 1表示竖屏，0表示横屏，其他表示跟随系统
                            orientation: 2,
                            success: function(result) {
                                showTips(JSON.stringify(result));
                            },
                            error: function(error) {
                                showTips('失败:' + JSON.stringify(error));
                            }
                        });
                        break;
                    case 'getDeviceId':
                        quick.device.getDeviceId({
                            success: function(result) {
                                showTips(JSON.stringify(result));
                            },
                            error: function(error) {
                                showTips('失败:' + JSON.stringify(error));
                            }
                        });
                        break;
                    case 'getVendorInfo':
                        quick.device.getVendorInfo({
                            success: function(result) {
                                showTips(JSON.stringify(result));
                            },
                            error: function(error) {
                                showTips('失败:' + JSON.stringify(error));
                            }
                        });
                        break;
                    case 'getNetWorkInfo':
                        quick.device.getNetWorkInfo({
                            success: function(result) {
                                showTips(JSON.stringify(result));
                            },
                            error: function(error) {
                                showTips('失败:' + JSON.stringify(error));
                            }
                        });
                        break;
                    case 'callPhone':
                        quick.device.callPhone({
                            phoneNum: '18262280461',
                            success: function(result) {
                                showTips(JSON.stringify(result));
                            },
                            error: function(error) {
                                showTips('失败:' + JSON.stringify(error));
                            }
                            // 兼容
                            // quick.device.callPhone('18262280461');
                        });
                        break;
                    case 'sendMsg':
                        quick.device.sendMsg({
                            phoneNum: '18262280461',
                            message: '测试短信',
                            success: function(result) {
                                showTips(JSON.stringify(result));
                            },
                            error: function(error) {
                                showTips('失败:' + JSON.stringify(error));
                            }
                            // 兼容
                            // quick.device.sendMsg('18262280461', '测试');
                        });
                        break;
                    case 'closeInputKeyboard':
                        quick.device.closeInputKeyboard({
                            success: function(result) {
                                showTips(JSON.stringify(result));
                            },
                            error: function(error) {
                                showTips('失败:' + JSON.stringify(error));
                            }
                            // 兼容
                            // quick.device.sendMsg('18262280461', '测试');
                        });
                        break;
                    case 'vibrate':
                        quick.device.vibrate({
                            duration: 1000,
                            success: function(result) {
                                showTips(JSON.stringify(result));
                            },
                            error: function(error) {
                                showTips('失败:' + JSON.stringify(error));
                            }
                            // 兼容
                            // quick.device.sendMsg('18262280461', '测试');
                        });
                        break;
                    default:
                        console.error('错误！没有相应API');
                }
            };
        </script>

    </body>

</html>